#include "PluginInterface.h"
#include "PacketPriority.h"
#include "RakPeerInterface.h"
#include "ChatOrder.h"

namespace ChatApp
{

class ChatClientPlugin : public PluginInterface
{
public:
	ChatClientPlugin();
	~ChatClientPlugin();

	void SetServerAddress( SystemAddress address );
	void SetFriendId( int friendId );
	unsigned char GetPacketId( Packet *p );

	OrderMessage CreateOrder( char *message );
	void OnSend( RakPeerInterface *peer, char *message );

	SystemAddress serverAddress;
	int friendRequest;

protected:
	PluginReceiveResult OnReceive( RakPeerInterface *peer, Packet *packet );
	void OnCloseConnection( RakPeerInterface *peer, SystemAddress systemAddress );
	void OnShutdown( RakPeerInterface *peer );
	DefaultChatOrder OnMessage ( Packet *packet );

private:
	bool IsOrder( char *message, char *order, int pos );
	bool IsNumber( char *message, int beginp, int endp );
	char* SubString( char *message, int beginp, int endp );

	unsigned int m_PackPos;

}; // End of ChatClentPlugin

}